Simple Example

Found here

To get specific parts of webpages, use selectorgadget

library(rvest)

myWebsite <- read_html("http://fdrennan.net")
     
rating <- myWebsite %>% 
  html_nodes(".bg5") %>%
  html_text()

head(rating)
## [1] "About Me"                    "Current Economic Indicators"
## [3] "Curriculum Vitae"            "Optimal Hubs"               
## [5] "Random Forest with Diamonds" "Random Forests"

Get the Weather in Numerous Locations

# loading the required packages
library(ggmap)

Get Lat/Lon

# creating a sample data.frame with your lat/lon points
cities = c("Atlanta", "Boston", "Chicago", "Denver", 
           "Houston", "Los Angeles", "New Orleans", 
           "New York", "Pittisburgh", "Salt Lake City", "San Francisco", "Seattle")

locations = geocode(cities)
head(locations)
##          lon      lat
## 1  -84.38798 33.74900
## 2  -71.05888 42.36008
## 3  -87.62980 41.87811
## 4 -104.99025 39.73924
## 5  -95.36980 29.76043
## 6 -118.24368 34.05223

Download Temperatures from weather.gov

df = data.frame(city = "NA", rating = "NA")

for(i in 1:length(cities)) {
     
     link = paste0("http://forecast.weather.gov/MapClick.php?lat=",
       locations[i,2],
       "&lon=",
       locations[i,1],"#.WPqPZXXyuV4")

     myWebsite <- read_html(link)
          
     rating <- myWebsite %>% 
       html_nodes(".myforecast-current-lrg") %>%
       html_text()
     
     city = cities[i]
     
     df = rbind(cbind(city, rating), df)

}
df = df[-nrow(df), ]

Plot the Temperatures

lat = locations$lat 
lon = locations$lon

locDf <- as.data.frame(cbind(lon,lat))
locDf = cbind(locDf,df[nrow(df):1,])
head(locDf)
##           lon      lat        city rating
## 12  -84.38798 33.74900     Atlanta   82°F
## 11  -71.05888 42.36008      Boston   44°F
## 10  -87.62980 41.87811     Chicago   51°F
## 9  -104.99025 39.73924      Denver   41°F
## 8   -95.36980 29.76043     Houston   81°F
## 7  -118.24368 34.05223 Los Angeles   83°F
# getting the map
map <- get_map(location = "Kansas", zoom = 4,
                      maptype = "satellite", scale = 2)
## Map from URL : http://maps.googleapis.com/maps/api/staticmap?center=Kansas&zoom=4&size=640x640&scale=2&maptype=satellite&language=en-EN&sensor=false
## Information from URL : http://maps.googleapis.com/maps/api/geocode/json?address=Kansas&sensor=false
locDf$lon = as.numeric(as.character(locDf$lon))
locDf$lat = as.numeric(as.character(locDf$lat))
locDf$rating = as.character(locDf$rating)
# plotting the map with some points on it
p <- ggmap(map)+ 
     geom_text(data=locDf, 
                aes(x=lon, y=lat, label = rating), size=5, col = "light blue") 
p